package com.ruoyi.web.controller.front;

import java.util.List;

import com.ruoyi.common.utils.UUIDFactory;
import com.ruoyi.front.domain.SWebMenu;
import com.ruoyi.front.service.ISWebMenuService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.front.domain.SWebMenuInfo;
import com.ruoyi.front.service.ISWebMenuInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * webMenuInfoController
 * 
 * @author jyp
 * @date 2021-07-25
 */
@Controller
@RequestMapping("/front/webMenuInfo")
public class SWebMenuInfoController extends BaseController
{
    private String prefix = "front/webMenuInfo";

    @Autowired
    private ISWebMenuInfoService sWebMenuInfoService;
    @Autowired
    private ISWebMenuService sWebMenuService;

    @RequiresPermissions("front:webMenuInfo:view")
    @GetMapping()
    public String webMenuInfo()
    {
        return prefix + "/webMenuInfo";
    }

    /**
     * 查询webMenuInfo列表
     */
    @RequiresPermissions("front:webMenuInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SWebMenuInfo sWebMenuInfo)
    {
        startPage();
        List<SWebMenuInfo> list = sWebMenuInfoService.selectSWebMenuInfoList(sWebMenuInfo);
        return getDataTable(list);
    }

    /**
     * 导出webMenuInfo列表
     */
    @RequiresPermissions("front:webMenuInfo:export")
    @Log(title = "webMenuInfo", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SWebMenuInfo sWebMenuInfo)
    {
        List<SWebMenuInfo> list = sWebMenuInfoService.selectSWebMenuInfoList(sWebMenuInfo);
        ExcelUtil<SWebMenuInfo> util = new ExcelUtil<SWebMenuInfo>(SWebMenuInfo.class);
        return util.exportExcel(list, "webMenuInfo");
    }

    /**
     * 新增webMenuInfo
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }
    /**
     * 新增webMenuInfo
     */
    @GetMapping("/addWebMenuInfo")
    public String addWebMenuInfo(ModelMap mmap,String id)
    {
         SWebMenu sWebMenu = new SWebMenu();
         List<SWebMenu> list = sWebMenuService.selectSWebMenuList(sWebMenu);
         mmap.put("list",list);
         mmap.put("id",id);
        return prefix + "/addWebMenuInfo";
    }

    /**
     * 新增保存webMenuInfo
     */
    @RequiresPermissions("front:webMenuInfo:add")
    @Log(title = "webMenuInfo", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SWebMenuInfo sWebMenuInfo)
    {
        sWebMenuInfo.setId(UUIDFactory.getStringId());
        return toAjax(sWebMenuInfoService.insertSWebMenuInfo(sWebMenuInfo));
    }

    /**
     * 修改webMenuInfo
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        SWebMenuInfo sWebMenuInfo = sWebMenuInfoService.selectSWebMenuInfoById(id);
        mmap.put("sWebMenuInfo", sWebMenuInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存webMenuInfo
     */
    @RequiresPermissions("front:webMenuInfo:edit")
    @Log(title = "webMenuInfo", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SWebMenuInfo sWebMenuInfo)
    {
        return toAjax(sWebMenuInfoService.updateSWebMenuInfo(sWebMenuInfo));
    }

    /**
     * 删除webMenuInfo
     */
    @RequiresPermissions("front:webMenuInfo:remove")
    @Log(title = "webMenuInfo", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sWebMenuInfoService.deleteSWebMenuInfoByIds(ids));
    }
}
